#include <iostream>
using std::cout;
using std::endl;

class Point{
public:
    Point(){
        cout << "Point()" << endl;
    }

    Point(int x,int y)
    : _ix(x)
    , _iy(y)
    {
        cout <<"Point(int,int)" << endl;
    }

    void print(){
        cout << "(" << _ix << ","
            << _iy << ")" ;
    }
    
    ~Point(){ cout << "~Point()" << endl; }
private:
    int _ix;
    int _iy;
};

class Line{
public:
    Line(int x1,int y1,int x2,int y2)
    //如果在Line构造函数的初始化列表中不显式地写出Point类子对象
    //的构造，会默认调用Point的无参构造
    //
    //如果想要调用Point类的其他构造函数对Line的对象成员进行初始化
    //需要手动地在初始化列表中给出
    : _pt1(x1,y1)
    , _pt2(x2,y2)
    {
        cout << "Line(int * 4)" << endl;
    }

    void printLine(){
        //_pt1和_pt2是Line类的对象成员
        //那么在Line类中可以通过_pt1/_pt2去调用
        //Point类的成员函数
        _pt1.print();
        cout << "--->";
        _pt2.print();
        cout << endl;

    }
    
    ~Line(){ cout <<"~Line()" << endl; }
private:
    Point _pt1;
    Point _pt2;
};

void test0(){
    Line ll(1,2,3,4);
    ll.printLine();
}

int main(void){
    test0();
    return 0;
}
